﻿@using ZBJF.Warranty.WebProvider
@{
    ViewBag.Title = "Index";
}
@section Header{
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
}
<ul class="nav nav-tabs">
    <li class="active"><a href="/D_City/">城市列表</a></li>
    <li class="Add-R"><a target="_blank" href="/D_City/Edit/0">添加城市</a></li>
</ul>
<form id="searchForm" class="breadcrumb form-search">
    <div>
        <label>关键词：</label><input id="Keyword" name="Keyword" class="input-medium" placeholder="请输入搜索关键词" type="text" value="" maxlength="50" />
        <input id="btnSubmit" class="btn btn-primary Search-R" type="button" value="查询" onclick="search();">
    </div>
</form>
<div class="table-responsive dataTables_wrapper">
    <table id="list" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th width="20">序号</th>
                <th width="100">省份</th>
                <th width="100">城市</th>
                <th width="100">排序</th>
                <th width="80">是否热门</th>
                <th width="80">首字母</th>
                <th width="80">邮编</th>
                <th width="80">状态</th>
                <th width="100">操作</th>
            </tr>
        </thead>
    </table>
</div>
@section scripts{
    @Scripts.Render("~/Bundles/ImagePreview")
    <script type="text/javascript">
        var isSearch = false;
        $(function () {
            var objTable = $("#list")
                .dataTable({
                    fnDrawCallback: function () {
                        ControlPermissionOperate();
                    },
                    "sAjaxSource": "/D_City",
                    aoColumns: [
                        {
                            "mData": null, "fnRender": function (nRow) {
                                return nRow.iDataRow + 1;
                            }
                        },
                        { "mData": "ProvinceName" },
                        {
                            "mData": "CityName", "fnRender": function (nRow) {
                                return "<a class='Edit-R' target='_blank'  href='/D_City/Edit/" + nRow.aData.CityID + "' title='edit'>" + nRow.aData.CityName + "</a>";
                            }
                        },
                        { "mData": "Sort" },
                        { "mData": null },
                        { "mData": "Letter" },
                        { "mData": "ZipCode" },
                        { "mData": null },
                        { "mData": null }
                    ],
                    "fnRowCallback": function (nRow, aData, iDisplayIndex) {
                        $('td:eq(4)', nRow).html(aData.Hot ? "是" : "否");
                        $('td:eq(7)', nRow).html(aData.IsAvailable ? bootStrapOkIncon : bootStrapRemoveIncon);
                        var html = "<a class='Edit-R' target='_blank' href='/D_City/Edit/" + aData.CityID + "' title='edit'><i class='icon-edit'></i></a>";
                        html += "<a class='Edit-R' href=\"javascript:UpdateStatus('" + aData.CityID + "'," + !aData.IsAvailable + ",'/D_City/UpdateStatus','list')\" title='" + (aData.IsAvailable ? "禁用" : "启用") + "'>" + (aData.IsAvailable ? bootStrapRemoveIncon : bootStrapOkIncon) + "</a>";
                        $('td:eq(8)', nRow).html(html);
                    }
                });
        });

        function search() {
            /*给查询对象赋值*/
            queryParamList.Keyword = ($("#Keyword").val());
            $("#list").dataTable().fnDraw();
        }

    </script>
}


